
/****************************************************************************/
/*Copyright (c) 2011, Florent DEVILLE.                                      */
/*All rights reserved.                                                      */
/*                                                                          */
/*Redistribution and use in source and binary forms, with or without        */
/*modification, are permitted provided that the following conditions        */
/*are met:                                                                  */
/*                                                                          */
/* - Redistributions of source code must retain the above copyright         */
/*notice, this list of conditions and the following disclaimer.             */
/* - Redistributions in binary form must reproduce the above                */
/*copyright notice, this list of conditions and the following               */
/*disclaimer in the documentation and/or other materials provided           */
/*with the distribution.                                                    */
/* - The names of its contributors cannot be used to endorse or promote     */
/*products derived from this software without specific prior written        */
/*permission.                                                               */
/* - The source code cannot be used for commercial purposes without         */ 
/*its contributors' permission.                                             */
/*                                                                          */
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT         */
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS         */
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE            */
/*COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,       */
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,      */
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;          */
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER          */
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT        */
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN         */
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE           */
/*POSSIBILITY OF SUCH DAMAGE.                                               */
/****************************************************************************/

#pragma once

#include "CMaterialComponent.h"

class IProcTexture;
class CTexture;

class CMaterial
{
private:
	//represent the ambient component of the material
	CMaterialComponent _ambient;

	//represent the diffuse component of the material
	CMaterialComponent _diffuse;

	//represent the specular component of the material
	CMaterialComponent _specular;

	
public:
	//specular (phong)
	//CColor m_specular;
	float m_shininess;

	//reflection
	CColor m_reflect;

	//refraction coefficient
	double m_refractionIndex;

private:

	//IProcTexture* m_proceduralTexture;
	IProcTexture* m_bumpMap;
	
	CTexture* m_diffuseTexture;

public:
	//constructor
	CMaterial();

	//destructor
	virtual ~CMaterial();

	//set the ambient component using a color
	void setAmbient(const CColor& ambient);

	//set the ambient component using a procedural texture
	void setAmbient(IProcTexture* const procTexture);

	//set the ambient component using a texture from a file
	void setAmbient(CTexture* const fromFileTexture);

	//set the diffuse component using a color
	void setDiffuse(const CColor& diffuse);

	//set the diffuse component using a procedural texture
	void setDiffuse(IProcTexture* const procTexture);

	//set the diffuse component using a file texture
	void setDiffuse(CTexture* const fromFileTexture);

	//set the specular component using a color
	void setSpecular(const CColor& specular);

	//set the specular component using a procedural texture
	void setSpecular(IProcTexture* const procTexture);

	//set the specular component using a file texture
	void setSpecular(CTexture* const fromFileTexture);

	//settors
	void setBumpMap(IProcTexture* bump);

	//Return the diffuse color of the component on the point v in the primitive p.
	CColor getDiffuse(const CVector3f& v, const IPrimitive& p)const;

	//Return the ambient color of the component on the point v in the primitive p.
	CColor getAmbient(const CVector3f& v, const IPrimitive& p)const;

	//Return the specular color of the component on the point v in the primitive p.
	CColor getSpecular(const CVector3f& v, const IPrimitive& p)const;

	//return the normal of the point using a bump mapping texture
	CVector3f getBumpNormal(const CVector3f& v)const;


	bool useBumpMapping()const;

};